package org.douxiaoban.client.activity;

import org.douxiaoban.client.R;
import org.douxiaoban.client.app.App;
import org.douxiaoban.client.widget.PopupSearchBar;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

import com.feedback.NotificationType;
import com.feedback.UMFeedbackService;
import com.mobclick.android.MobclickAgent;

/**
 * Created by IntelliJ IDEA.
 * User: huangzhongkun
 * Date: 11-7-2
 * Time: 下午4:55
 */
public class BaseActivity extends Activity {
    private App _app ;
    protected PopupSearchBar _searchbar;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        _app = (App)getApplication();
        _searchbar = new PopupSearchBar(this);

    }

    @Override
    public void onResume(){
    	super.onResume();
    	MobclickAgent.onResume(this);
    }
    
    @Override
    public void onPause(){
    	super.onPause();
    	MobclickAgent.onPause(this);
    }
    
    
     @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu,menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        _app.mentOptions(item.getItemId(),this);
        return true; 
    }
    
    @Override
   	public boolean onKeyDown(int keyCode, KeyEvent event) {
   		switch (keyCode) {
   		case KeyEvent.KEYCODE_SEARCH:
   			_searchbar.showSearchBar();
   			return true;
   		}
   		return super.onKeyDown(keyCode, event);
   	}
    
}